home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / edit / gal210a3.zip / LANCEANA.DOC < prev    next >
Text File  |  1984-11-04  |  16KB  |  440 lines

  1.         Lancelot documentation for programming the analyzer
  2.         ---------------------------------------------------
  3.  
  4.      Lancelot analyzes languge by interpreting commands given in an
  5. analysis file.  The commands are called actions which have a particular form.
  6. Each action starts with a word, called a dot-dot command e.g.,  ..WORD,
  7. followed by a print message and then followed by one or more elements as
  8. defined below.
  9.  
  10.      Several sample (and useful) analysis files are included with Lancelot,
  11. and typical usage should be inferred from reading them.  They do not all use
  12. all of the options of Lancelot, and so are not a substitute for reading this
  13. documentation.
  14.  
  15.      The commands are given below in alphabetical order.  Occasionally
  16. there are common points between the commands, and they are discussed in a note
  17. to the reader.  The syntactic form of a command is followed by the semantics
  18. of the command.
  19.  
  20.  
  21.  
  22.                              Definitions
  23.  
  24. Print messages
  25.  
  26.      Print messages contain an arbitrary number of text lines which may or
  27. may not be printed depending upon where it appears in an action.  A print
  28. message begins on a line that starts with a colon, and continues to the next
  29. line that starts with a dot or colon.  Print messages may contain variables
  30. whose value will be substituted when the message is printed.
  31.  
  32.      Occasionally you may wish to print nothing in a print message.  You
  33. may accomplish that using the following print message which is called the
  34. empty print message:
  35.  
  36. :.
  37.  
  38.      Blank lines before a print message are ignored, while blank lines
  39. after a print message are included in the print message.  This happens
  40. because print messages do not stop until the next dot or dot-dot command.
  41.  
  42.  
  43. Variables
  44.  
  45.      Variables are words that start with a sharp sign (#).  Lancelot
  46. defines a number of variables that are set by various dot-dot commands.  The
  47. value that the variable takes on is described below with the dot-dot command
  48. that sets the variable.  You may define your own variables using the ..CALC
  49. command.  These variables may be used in the same manner as Lancelot's
  50. variables.  Lancelot's variables are all uppercase to make them stand out from
  51. the rest of the print message.  We suggest that your variables be given in
  52. uppercase also.  Case is significant in variable names.
  53.  
  54.  
  55. Numbers
  56.  
  57.      Some of the dot-dot commands have numbers as arguments.  When the syntax
  58. of the dot-dot command is given, the numbers are given names and enclosed in
  59. angle brackets (<>).  For example, <lower_bound> means a number whose value
  60. is used as a lower bound.
  61.  
  62.  
  63. Literal words and search words.
  64.  
  65.      Lancelot has two concepts of a word, the literal word and the search
  66. word.  The literal word is a word that must occur literally in the text, and
  67. is used by the ..MOST, ..SIZE, ..SHOW, and ..WORD commands.  Literal words are
  68. not sensitive to case.  Search words are used by phrase matching and
  69. conditional matching dot-dot commands, and are more powerful (and slower) than
  70. literal words.
  71.  
  72.      If a letter in a search word is capitalized, that letter matches
  73. either upper or lower case text letters.  A text word is terminated by one of
  74. the following characters: .?!,;)<space><tab><return><linefeed>.  If a search
  75. word contains a star (*), the star matches as many text characters as
  76. possible.  If a search word contains a percent (%), then that percent matches
  77. one or more of the following characters: <space><tab><cr><lf>.  Percent
  78. characters are useful only in conditional matching.  Examples:
  79.  
  80.   Analysis     Matching Text
  81.   --------     -------------
  82.   *ing            ing
  83.                   ring
  84.                   cling
  85.                   string
  86.  
  87.   Crawl*          crawl
  88.                   Crawl      {note that C matches both upper and lower case}
  89.                   crawled
  90.                   crawling
  91.  
  92.   a*c             ac
  93.                   abc
  94.                   abbc
  95.                   abbbc
  96.                   abbbbc
  97.  
  98.   in%to           "in to"
  99.                   "in       to"
  100.                   "in
  101.                   to"
  102.                   "in
  103.                     to"
  104.  
  105.  
  106.  
  107.  
  108.  
  109.                     Syntax of a Lancelot Action
  110.                     ----------------------------
  111.  
  112. 1. All actions start with a dot-dot command which determines the action to
  113.    occur.  For example: ..WORD means that single words are to be searched
  114.    in the text.  ..ALLCOND means that all sentences of the text are to be
  115.    searched to determine if they contain a specified word or sequence of
  116.    words.
  117.  
  118. 2. The second element of an action is an unconditional print message which is
  119.    always printed (don't forget that :. prints nothing.)
  120.  
  121. 3. The third element of an action is one or more literal words or search
  122.    words which are to be acted upon.  The particular action taken depends
  123.    upon the dot-dot command.
  124.  
  125. 4. The fourth element is a conditional print message that is printed only if
  126.    the literal or search word(s) were found.
  127.  
  128. 5. Optionally, most dot-dot commands allow any number of pairs of element 3
  129.    and element 4 to be repeated any number of times.
  130.  
  131. 6. An action is terminated by another dot-dot command.
  132.  
  133. For example:
  134.  
  135. ..allcond                                                        {Element 1}
  136. :Your text is now being searched for three word constructions.   {Element 2}
  137. .Ha* .preference                                                 {Element 3}
  138. :The text says "has(have)...a preference."  Say "prefer."        {Element 4}
  139. .Spell* .out                                                     {Element 3}
  140. :The text says "spell(s)...out."  Say "explain(s)."              {Element 4}
  141. .Take* .consideration
  142. :The text says "take(s)....Consideration."  Say "consider(s)."
  143. ..end                                                            {Element 6}
  144.  
  145.  
  146. Lancelot Dot-dot Commands
  147.  
  148. -------------------------------------------------------------
  149.  
  150. ..allcond
  151. :print message (unconditional)
  152. .word1 .word2 .word3 ...
  153. :print message (conditional upon finding a phrase containing the above words)
  154. .optional next element 3
  155. :optional next element 4
  156.  
  157.      The text is searched for all sentences that contain search word .WORD1
  158. followed by zero or more words followed by any one of .WORD2, .WORD3, or ....
  159. If the element consists of just .WORD1, then those sentences that contain
  160. .WORD1 will be accepted and the conditional print statement will be printed.
  161. If the element contains .WORD1 and .WORD2 then a sentence is accepted only if
  162. it contains both .WORD1 and .WORD2 in the respective order.  Note that .WORD1
  163. may be an entire text phrase by using the percent character.
  164.  
  165.      When a sentence is found that is accepted and the conditional print
  166. message is not empty, not only is the element 4 print message printed but
  167. also a window of three text lines is displayed to the user.  This window
  168. surrounds the place in the text where the phrase was found.  
  169.  
  170.      This action is repeated until all the occurrences in all sentences have
  171. been found.  The next element 3 is then used for the search.  Multiple
  172. elements in a single ..ALLCOND are equivalent to the same elements in multiple
  173. ..ALLCOND's.
  174.  
  175.      The variable #COUNT is set to the number of times the phrase is found,
  176. and #LINE is set to the last line in which the phrase is found.  Note that
  177. #LINE is set before the print message is printed, so the print message can
  178. print the line in which the phrase was found.
  179.  
  180. -------------------------------------------------------------
  181.  
  182. ..allphrase 
  183. :print message (unconditional) 
  184. .word1 word2 word3 ...   (NOTE: no dots - this is a phrase) 
  185. :print message (conditional upon finding the phrase.) 
  186. .optional next element 3 
  187. :optional next element 4
  188.  
  189.      The text is searched for all sentences that contain the phrase WORD1
  190. followed by WORD2, followed by WORD3 ...  If a sentence contains the
  191. phrase of element 3 then the sentence is accepted.
  192.  
  193.      When a sentence is found that is accepted and the conditional print
  194. message is not empty, not only is the element 4 print message printed but
  195. a